<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>角色用户</title>
		<style type="text/css">
body {
	text-align: center;
}

table thead {
	background-color: #AAD4FF;
}

table tbody {
	background-color: #E1E1E1;
}

table tfoot {
	background-color: #FAD0FA;
}

table tfoot input {
	background-color: #2AA9FE;
	margin-left: 20px;
	cursor: pointer;
}
</style>
<SCRIPT type="text/javascript"><!--
	function checkDate(roleid){
		var urlPath="";
		var tds = document.getElementsByTagName("form")[0]
						.getElementsByTagName("table")[0]
						.getElementsByTagName("tbody")[0]
						.getElementsByTagName("td");
		
		for(var i=0;i<tds.length;i++){
			var input = tds[i].getElementsByTagName("input");
			for(var j=0;j<input.length;j++){
				if(input[j].type=="checkbox" && input[j].checked){
					urlPath+= "&adminid="+input[1].value;					
					break;
				}
			}
		}
		var xmlhttp;
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		}else{// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {	
		    	document.getElementById("main_content").innerHTML=xmlhttp.responseText;
		    }
		}
		xmlhttp.open("POST","/control/mapping/role_updateAdmin.go?role.id="+roleid+urlPath,true);
		xmlhttp.send();
	}

	/**
	刷新页面
	**/
	function goBack(){
		var xmlhttp;
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		}else{// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {	
		    	document.getElementById("main_content").innerHTML=xmlhttp.responseText;
		    }
		}
		xmlhttp.open("POST",backURL,true);
		xmlhttp.send();
	}
	//加载页面的时候回去访问路径
	var backURL;
	window.onload = function(){
		backURL=document.URL;
	}
--></SCRIPT>
	</head>
	<body>
	<div id="main_content">
		<form action="">
			<table>
				<thead>
					<tr>
						<td colspan="5" style="text-align: center;">
							${role.name }
						</td>
					</tr>
				</thead>
				<tbody>
					<tr>
						<s:iterator value="admins" var="admin_list" status="st">
							<td>
								<s:if test="#admin_list.check==0"><INPUT type="checkbox"/></s:if>
								<s:elseif test="#admin_list.check==1"><INPUT type="checkbox" checked="checked"/></s:elseif>
								<s:else><INPUT type="image" src="/image/admin/pic19.gif"/></s:else>
								<input type="hidden" name="adminId" value="${admin_list.id }" />
								${admin_list.name }
							</td>
							<s:if test="#st.count%5==0">
					</tr>
					<tr>
						</s:if>
						</s:iterator>
					</tr>
				</tbody>
				<tfoot>
					<tr>
						<td colspan="5">
							<input type="button" value="&nbsp;确&nbsp;定&nbsp;" onclick="checkDate(${role.id})"/>
							<input type="reset" value="&nbsp;取&nbsp;消&nbsp;" />
						</td>
					</tr>
				</tfoot>
			</table>
		</form>
	</div>
	</body>
</html>